#define DEBUG
#include <cstdio>
#define MAXN 100000
#define MAXLEN 510000

using namespace std;

class Tree {
public:
  int n, m, to[MAXN+1], link[MAXN+1], ind[MAXN+1], size[MAXN+1];
  
  void addSide(int fa, int son) {
    m++;
    to[m] = son;
    link[m] = ind[fa];
    ind[fa] = m;
  }

  long long solve(int o, int fapos) {
    static int pos=-1;
    long long ret=(++pos)-fapos, mypos=pos;
    for (int i=ind[o]; i; i=link[i]) {
      ret += solve(to[i], mypos);
    }
    return ret;
  }
};

class Trie {
public:
  Trie *son[26];
  int size, pos;
  bool flag=false;

  void add(char *s) {
    if (*s!='\0') {
      if (!son[(int)*s-'a']) {
	son[(int)*s-'a'] = new Trie();
      }
      son[(int)*s-'a']->add(s-1);
    } else {
      flag=true;
    }
  }

  void build(int fa, int *fat, int *sizea) {
    int next_fa=fa, o;
    static int n;
    size=0;
    if (flag) {
      size=1;
      next_fa=++n;
      o=n;
      fat[n] = fa;
    }
    for (int i=0; i<26; i++) {
      if (son[i]) {
	son[i]->build(next_fa, fat, sizea);
	size += son[i]->size;
      }
    }
    if (flag) {
      sizea[o] = size;
    }
  }
};

void sorts(int a[], char *b[], int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2];
  for (; i<=j; ) {
    for (; a[j]>mid; j--);
    for (; a[i]<mid; i++);
    if (i<=j) {
      int tempa;
      tempa=a[i], a[i]=a[j], a[j]=tempa;
      char *tempb;
      tempb=b[i], b[i]=b[j], b[j]=tempb;
      i++, j--;
    }
  }
  if (i<r) {
    sorts(a, b, i, r);
  }
  if (j>l) {
    sorts(a, b, l, j);
  }
}

void sort(int a[], int b[], int c[], int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2];
  for (; i<=j; ) {
    for (; a[j]<mid; j--);
    for (; a[i]>mid; i++);
    if (i<=j) {
      int temp;
      temp=a[i], a[i]=a[j], a[j]=temp;
      temp=b[i], b[i]=b[j], b[j]=temp;
      temp=c[i], c[i]=c[j], c[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, b, c, i, r);
  }
  if (j>l) {
    sort(a, b, c, l, j);
  }
}

int main() {
#ifdef DEBUG
  freopen("4631.in", "r", stdin);
  freopen("4631.out", "w", stdout);
#endif

  static int len[MAXN+1];
  static char *s[MAXN+1], str[MAXLEN+MAXN+1];
  int n;
  scanf("%d", &n);
  str[0]='\0';
  char *temp=str+1;
  for (int i=1; i<=n; i++) {
    scanf("%s", temp);
    for (; *temp!='\0'; temp++) {
      len[i]++;
    }
    s[i]=temp-1;
    temp++;
  }
  // sort(len, s, 1, n);

  Trie *t=new Trie();
  for (int i=1; i<=n; i++) {
    t->add(s[i]);
  }
  static int fa[MAXN+1], size[MAXN+1], id[MAXN+1];
  t->build(0, fa, size);
  for (int i=1; i<=n; i++) {
    id[i]=i;
  }
  sort(size, fa, id, 1, n);
  static Tree tree;
  for (int i=1; i<=n; i++) {
    tree.addSide(fa[i], id[i]);
    tree.size[id[i]]=size[id[i]];
  }
  printf("%lld", tree.solve(0, 0));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
